package com.mgface.framework.springboot.web;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mgface.framework.dao.BasedDao;
import com.mgface.framework.entity.RandomEntity2;
import com.mgface.framework.service.JudgeConditionService;

@RestController
public class ConditionController {
	private final static Logger log = LogManager.getLogger(ConditionController.class);

	@Autowired(required = false) // 就算不满足,也照样启动程序。否则会导致系统启动异常
	private JudgeConditionService judgeConditionService;
	
	@Autowired
	private BasedDao<String> basedao;//Spring容器可以使用泛型决定依赖注入。我们简单改变泛型的类型可自动注入所需要的bean
	
	@Autowired
	private RandomEntity2 randomEntity2;
	
	@RequestMapping(value = "/judge")
	private String judge() {
		log.info("打印entity2属性:{}",ToStringBuilder.reflectionToString(randomEntity2));
		log.info("basedao使用的泛型类型为:{},内存值:{}",basedao.getGenericName(),basedao);
		log.info("judgeConditionService是否为空:{}", judgeConditionService == null);
		if (judgeConditionService == null) {
			return "失败";
		}
		judgeConditionService.fromJudgeSay();
		return "成功";
	}
}
